package com.hele.sts.dao;

import java.util.List;

/**
 * @ClassName AdminUser
 * @Description TODO
 * @Author xuning
 * @Date 2019-05-16 08:53
 **/
public class AdminUser {

    private User user;
    private List<XtRole> xtRoleList;
    private List<XtMenu> xtMenuList;

    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }

    public List<XtRole> getXtRoleList() {
        return xtRoleList;
    }

    public void setXtRoleList(List<XtRole> xtRoleList) {
        this.xtRoleList = xtRoleList;
    }

    public List<XtMenu> getXtMenuList() {
        return xtMenuList;
    }

    public void setXtMenuList(List<XtMenu> xtMenuList) {
        this.xtMenuList = xtMenuList;
    }

    public String getRoleName(){
        if(this.xtRoleList==null||xtRoleList.size()==0){
            return "";
        }
        return xtRoleList.get(0).getName();
    }

    public boolean hasRole(String roleName){
        if(this.xtRoleList==null||xtRoleList.size()==0){
            return false;
        }
        for(XtRole xtRole:xtRoleList){
            if(roleName.equals(xtRole.getTips())){
                return true;
            }
        }
        return false;
    }

    public boolean hasMenu(String menuCode){
        if(this.xtMenuList==null||xtMenuList.size()==0){
            return false;
        }
        for(XtMenu xtMenu:xtMenuList){
            if(menuCode.equals(xtMenu.getCode())){
                return true;
            }
        }
        return false;
    }
}
